package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoArtCharacteristics;
import com.muyu.danmo.service.IDanmoArtCharacteristicsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 校园特色Controller
 *
 * @author yangle
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/artCharacteristics")
public class DanmoArtCharacteristicsController extends BaseController
{
    @Autowired
    private IDanmoArtCharacteristicsService danmoArtCharacteristicsService;

    /**
     * 查询校园特色列表
     */
//    @RequiresPermissions("system:artCharacteristics:list")
    @PostMapping("/list")
    public Result<List<DanmoArtCharacteristics>> list(@RequestBody DanmoArtCharacteristics danmoArtCharacteristics)
    {

        List<DanmoArtCharacteristics> list = danmoArtCharacteristicsService.selectDanmoArtCharacteristicsList(danmoArtCharacteristics);
        return Result.success(list);
    }

    /**
     * 导出校园特色列表
     */
//    @RequiresPermissions("system:artCharacteristics:export")
    @Log(title = "校园特色", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoArtCharacteristics danmoArtCharacteristics)
    {
        List<DanmoArtCharacteristics> list = danmoArtCharacteristicsService.selectDanmoArtCharacteristicsList(danmoArtCharacteristics);
        ExcelUtil<DanmoArtCharacteristics> util = new ExcelUtil<DanmoArtCharacteristics>(DanmoArtCharacteristics.class);
        util.exportExcel(response, list, "校园特色数据");
    }

    /**
     * 获取校园特色详细信息
     */
//    @RequiresPermissions("system:artCharacteristics:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoArtCharacteristicsService.selectDanmoArtCharacteristicsById(id));
    }

    /**
     * 新增校园特色
     */
//    @RequiresPermissions("system:artCharacteristics:add")
    @Log(title = "校园特色", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoArtCharacteristics danmoArtCharacteristics)
    {
        return toAjax(danmoArtCharacteristicsService.insertDanmoArtCharacteristics(danmoArtCharacteristics));
    }

    /**
     * 修改校园特色
     */
//    @RequiresPermissions("system:artCharacteristics:edit")
    @Log(title = "校园特色", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoArtCharacteristics danmoArtCharacteristics)
    {
        return toAjax(danmoArtCharacteristicsService.updateDanmoArtCharacteristics(danmoArtCharacteristics));
    }

    /**
     * 删除校园特色
     */
//    @RequiresPermissions("system:artCharacteristics:remove")
    @Log(title = "校园特色", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoArtCharacteristicsService.deleteDanmoArtCharacteristicsByIds(ids));
    }
}
